Database reference guide

HOME

SELECT Statement

The essential elements of a basic NSQL query are the SELECT and FROM clauses. The simplest form of query does not require a WHERE statement.

The following statement will create a Domain of all records in the customer table and select all the columns in that table:

SELECT *

FROM Customer;

Record Forename Surname Gender Age Town
0 HILDA SMITH F 35 BRISTOL
1 JOHN SMITH M 42 CARDIFF
2 PAUL JONES M 21 CARDIFF
3 SARAH BROWN F 22 CHESTER
4 ALISON SMYTH F 21 BRISTOL
5 DOUG SMALL M 35 CHESTER
6 IAN WRIGHT M 68 BATH
7 SAMANTHA NEWTON   35 CHESTER
8 FLORENCE LANE F 61 CARDIFF
9 DAVID ROGERS M 23 BATH
10 HELEN LAKER F 21 BATH

Obtaining Counts of Records

To obtain a count of records, Count(*) or # can be used.

The following statements are identical in their execution and will both create a domain of all records in the customer table:

SELECT Count(*)

FROM Customer;

SELECT #

FROM Customer;

The domains produced by these queries will contain all records in the customer table, but will select no columns for viewing.

This is the fastest and simplest way to get a count of the number of records in a Domain. If columns are not required for viewing, then a count query should be executed.

Obtaining specified records

To select specific columns for viewing in the Domain, simply list them after the SELECT statement.

The following statement will return all forenames in the specified table:

SELECT Forename

FROM Customer;

Record Forename
0 HILDA
1 JOHN
2 PAUL
3 SARAH
4 ALISON
5 DOUG
6 IAN
7 SAMANTHA
8 FLORENCE
9 DAVID
10 HELEN

Up to 100 columns can be specified explicitly in the SELECT clause

Note: This limit does not apply to Engine 3.1 and later

SELECT Sex,Age

FROM Customer;

Record Gender Age
0 F 35
1 M 42
2 M 21
3 F 22
4 F 21
5 M 35
6 M 68
7   35
8 F 61
9 M 23
10 F 21

  Online & Instructor-Led Courses | Training Videos | Webinar Recordings
© Alterian. All Rights Reserved. | Privacy Policy | Legal Notice